package com.cn.crmsystem.controller.approveController;

import com.cn.crmsystem.pojo.Approve;
import com.cn.crmsystem.pojo.ResultJson;
import com.cn.crmsystem.service.approveService.InvoicesService;
import io.swagger.annotations.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;
@Controller
@Api(value = "审核发票api",tags = "审核发票API")
public class InvoiceController {
	@Autowired
	InvoicesService invoiceService;
	//查询
	@RequestMapping(value = "/SelectInvoice",name = "查询审核发票",method = RequestMethod.POST)
	@ApiOperation(value = "查询审核发票",notes = "查询",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userid",value = "用户id",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public ResultJson SelectInvoice(@RequestParam(name = "userid") Integer userid){
		ResultJson resultJson=new ResultJson();
		resultJson=invoiceService.InvoiceSelect(userid);
		return resultJson;
	}
	//修改
	@RequestMapping(value = "/InvoiceUpdate",name = "修改审核发票",method = RequestMethod.POST)
	@ApiOperation(value = "修改发票",notes = "修改审核发票",httpMethod = "POST", response = String.class)
	@ResponseBody
	public  ResultJson InvoiceUpdate(@RequestBody
								   @ApiParam(name = "通过或者拒绝",value = "状态更新",required = false)Approve AP){
		Integer appid=AP.getApp_Id();
		Integer  state=AP.getState();
		ResultJson resultJson=new ResultJson();
		resultJson=invoiceService.UpdateInvoice(appid,state);
		return  resultJson;
	}
	//删除
	@RequestMapping(value = "/DeleteInvoice",name = "删除审核发票",method = RequestMethod.POST)
	@ApiOperation(value = "删除发票",notes = "更改deleteid",httpMethod = "POST", response = String.class)
	@ResponseBody
	public  ResultJson DeleteInvoice(@RequestBody
								   @ApiParam(name = "删除",value = "删除",required = false)	Approve AP){
		ResultJson resultJson=new ResultJson();
		Integer appid=AP.getApp_Id();
		resultJson=invoiceService.DeleteInvoice(appid);
		return  resultJson;
	}
	//条件查询
	@RequestMapping(value = "/SelectCondtionInvoice",name = "条件查询审核发票",method = RequestMethod.POST)
	@ApiOperation(value = "条件查询",notes = "查询",httpMethod = "POST", response = String.class)
	@ApiImplicitParams({
			@ApiImplicitParam(name = "userid",value = "用户id",paramType = "query",dataType = "Integer",required = false),
			@ApiImplicitParam(name = "state",value = "审核状态",paramType = "query",dataType = "Integer",required = false)
	})
	@ResponseBody
	public ResultJson SelectCondtionInvoice(@RequestParam(name = "userid") Integer userid,
											 @RequestParam(name = "state") Integer state ){
		ResultJson resultJson=new ResultJson();
		resultJson=invoiceService.SelectConditionInvoice(userid,state);
		return resultJson;
	}
}
